package cn.wolfcode.trip.base.domain;

import com.alibaba.druid.support.json.JSONUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;

@Setter
@Getter
public class Question extends BaseDomain {

    private String title; // 标题

    private String content; // 内容

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime; // 提问时间

    private User user; // 提问用户

    private String place; // 提问地区

    private int commentCount; // 评论总数

    private int answerCount; // 回答总数

    private int viewCount; // 浏览量

    private int likeCount; // 浏览量

    private int followCount; // 浏览量

    private String coverUrl; // 封面图

    public String getJson(){
        HashMap<Object, Object> map = new HashMap<>();
        map.put("id", this.id);
        map.put("content", this.content);
        return JSONUtils.toJSONString(map);
    }

}